<!--
  - Copyright (c) 2018.
  - 北京九思金信科技有限公司对该文件内容保留所有权利。
  - 未经许可，不得私自拷贝、传播、发布、引用该文件内容，违者将被追究法律责任。
  -->
<template>
  <span>{{contrastData}}</span>
</template>

<script>
export default {
  name: "JoysEnums",
  data() {
    return {
      contrastData: ""
    };
  },
  props: {
    serviceName: {
      default: ""
    },
    typeName: {
      default: ""
    },
    contrast: {
      default: ""
    }
  },
  methods: {
    QueryEnum(serviceName, typeName, contrast) {
      console.log(serviceName, typeName, contrast, "");
      this.$axios({
        method: "get",
        url: "/joys-rest/" + serviceName + "/enums/" + typeName + "/items",
        headers: {
          "AUTH-TOKEN": localStorage.getItem("AUTH-TOKEN"),
          "Content-Type": "application/json;charset=UTF-8"
        }
      })
        .then(res => {
          console.log(res, "");
          for (let key in res.data) {
            if (res.data[key].value == contrast) {
              this.contrastData = res.data[key].label;
            }
          }
        })
        .catch(error => {
          console.log(error, "枚举获取失败");
        });
    }
  },
  mounted() {
    setTimeout(() => {
      if (this.serviceName && this.typeName && this.contrast) {
        this.QueryEnum(this.serviceName, this.typeName, this.contrast);
      }
    }, 50);
  }
};
</script>

<style>
</style>
